<?php
/**
 * 活动页
 */
use Biz\service\activity\Page;
use Biz\tools\GoodsExposureLog;

class PageAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;
    
    public function main()
    {
        $pageId = $this->getRequest()->getQuery('page_id');
        $preview = $this->getRequest()->getQuery('preview');
        $date = $this->getRequest()->getQuery('date');
        $uid = $this->uid;
        if ($pageId) {
            //启动屏广告
            if ($uid > 0) {
                //设置缓存阻止首页弹屏
                \Doraemon\cache\PositionModule\AdCounter::setItem($uid, 1);
            }
            \Doraemon\tools\ActionLog::log($uid, ['page_id' => $pageId], \Doraemon\tools\ActionLog::ACTIVITY_PAGE);
            $pageInfo = Page::getPageInfo($pageId, $preview, $date, $uid);
            $this->setSuccess($pageInfo);
            GoodsExposureLog::addLog($this->getRequest(), $pageInfo, $pageId);
        } else {
            throw new Exception('参数错误');
        }
    }
    
}